<?php
class Front_Form_Tournois extends Jnd_Form
{
    protected $_connecte = false;

    public function __construct( $decorateur = "Formulairejndpro", $options = null )
    {
        if (isset($options['connecte'])) {
            $this->_connecte = (boolean) $options['connecte'];
        }
        parent::__construct($decorateur, $options);
        $this->setElementDecorators(array(
            "$decorateur"
        ), array(), false);
    }

    public function init()
    {
        $this->setName("tournois");
        $this->setMethod("post");
        $this->addAttribs(array(
            "class" => "cssform"
        ));
        
        $champ = new Zend_Form_Element_Hidden("id");
        $champs[] = $champ;
        
        if ($this->_connecte) {
            $champ = new Jnd_Form_Element_HiddenDisplay("nom");
        } else {
            $champ = new Zend_Form_Element_Text("nom");
            $champ->setRequired(true);
        }
        $champ->setLabel(__("Nom"));
        $champs[] = $champ;
        
        if ($this->_connecte) {
            $champ = new Jnd_Form_Element_HiddenDisplay("prenom");
        } else {
            $champ = new Zend_Form_Element_Text("prenom");
            $champ->setRequired(true);
        }
        $champ->setLabel(__("Prénom"));
        $champs[] = $champ;
        
        $champ = new Jnd_Form_Element_HiddenDisplay("nomTournoi");
        $champ->setLabel(__("Tournoi"));
        $champs[] = $champ;
        
        $champ = new Jnd_Form_Element_HiddenDisplay("date");
        $champ->setLabel(__("Date du tournoi"));
        $champs[] = $champ;
        
        $champ = new Jnd_Form_Element_HiddenDisplay("heure");
        $champ->setLabel(__("Heure de début"));
        $champs[] = $champ;
        
        $champ = new Jnd_Form_Element_HiddenDisplay("lieu");
        $champ->setLabel(__("Lieu du tournoi"));
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Checkbox("presence");
        $champ->setLabel(__("Sera présent"));
        $champ->setRequired(true);
        $champ->setCheckedValue("1");
        $champ->setUncheckedValue("0");
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Textarea("apporte");
        $champ->setLabel(__("J'apporterai"));
        $champ->setRequired(true);
        $champs[] = $champ;
                
        $this->addElements($champs);
    }
}

